<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});
Route::get('/', function () {
    return 'hello api';
    // return view('welcome');
});

//此版本可用 
Route::group(['prefix'=>'user', 'namespace' => 'Api'], function() {
    //用户注册
    Route::post('register', 'UserController@register');
    //用户登录
    Route::post('login', 'UserController@login');

    Route::middleware('api.refresh')->group(function() {
        //当前用户信息
        Route::get('info', 'UserController@info');
        Route::post('changepw', 'UserController@changePw');
        //用户退出
        Route::post('logout', 'UserController@loginOut');
    });
});